import 'dart:convert';

import 'ni_base_model.dart';
import 'ni_geopoint_model.dart';

///marker 数据信息
class NIRasterTileLayer implements NIModel {
  String? url;
  String? tilePath;
  String? title;
  String? imagePath;
  bool? cache;
  bool? isSelect;
  bool? isDel;

  NIRasterTileLayer({required this.url,required this.tilePath, required this.title,required this.imagePath,required this.cache,required this.isSelect,required this.isDel});

  factory NIRasterTileLayer.fromJson(String json) {
    Map<String, dynamic> map = jsonDecode(json);
    return NIRasterTileLayer.fromMap(map);
  }

  factory NIRasterTileLayer.fromMap(Map<dynamic, dynamic> map) {
    return NIRasterTileLayer(
      url: map['url'],
      tilePath: map['tilePath'],
      title: map['title'],
      imagePath: map['imagePath'],
      cache: map['cache'],
      isSelect: map['isSelect'],
      isDel: map['isDel'],
    );
  }

  @override
  String toJson() {
    return '{"url":${url == null ? "" : url!},"tilePath": ${tilePath == null ? "" : tilePath!}, "title": ${title == null ? "" : title!}, "imagePath": ${imagePath == null ? "" : imagePath!}, "cache": ${cache == null ? false : cache!}, "isSelect": ${isSelect == null ? false : isSelect!}, "isDel": ${isDel == null ? false : isDel!}}';
  }

  @override
  Map<String, dynamic> toMap() {
    return {
      "title": title == null ? "" : title!,
      "url": url == null ? "" : url!,
      "tilePath": tilePath == null ? "" : tilePath!,
      "imagePath": imagePath == null ? "" : imagePath!,
      "cache": cache == null ? false : cache!,
      "isSelect": isSelect == null ? false : isSelect!,
      "isDel": isDel == null ? false : isDel!,
    };
  }
}
